package world.liquor.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import world.liquor.domain.BeerAssessment;
import world.liquor.domain.BeerInfo;

@Repository
public class RecommendDAOImpl implements RecommendDAO {
	
	@Autowired
	private SqlMapClientTemplate sqlMap;

	public RecommendDAOImpl(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}

	public RecommendDAOImpl() {
	}

	//property 를 통해 주입
	public void setSqlMap(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}
	// 맥주 평가지 조회 by 회원 ID
	@Override
	public ArrayList<BeerAssessment> selectBeerAssessmentbyMemberId(
			String memberId) throws SQLException {
		HashMap map = new HashMap();
		map.put("memberId", memberId);
		return (ArrayList<BeerAssessment>) sqlMap.queryForList("selectBeerAssessmentbyMemberId", map);
	}
	
	// 맥주 정보 조회 by 맥주정보Id
	@Override
	public BeerInfo selectBeerInfobyBeerInfoId(String BeerInfoId)
			throws SQLException {
		HashMap map = new HashMap();
		map.put("BeerInfoId", BeerInfoId);
		return (BeerInfo) sqlMap.queryForObject("selectBeerInfobyBeerInfoId", map);
	}
	
	// 맥주 정보 조회 by 평가되지 않은 맥주
	@Override
	public ArrayList<BeerInfo> selectBeerInfobyremovebeerAssessmentIdOfMemberIdList(String memberId) 
			throws SQLException {
		HashMap map = new HashMap();
		map.put("memberId", memberId);
		return (ArrayList<BeerInfo>) sqlMap.queryForList("selectBeerInfobyremovebeerAssessmentIdOfMemberIdList", map);
	}

	@Override
	// 모든 맥주 평가지 조회
	public ArrayList<BeerAssessment> selectbeerAssessmentAll()
			throws SQLException {
		return (ArrayList<BeerAssessment>) sqlMap.queryForList("selectbeerAssessmentAll");
	}

	@Override
	//모든 맥주 정보 조회
	public ArrayList<BeerInfo> selectBeerInfoAll() throws SQLException {
		return (ArrayList<BeerInfo>) sqlMap.queryForList("selectBeerInfoAll");
	}


	
	



}
